#!/usr/bin/python

from abc import ABCMeta,abstractmethod

class StoreInterface:
    __metaclass__ = ABCMeta

    # Returns a map from metadata version number to timestamp
    @abstractmethod
    def ListMetadata(self): pass

    # Returns a string containing the contents of the given version number
    @abstractmethod
    def GetMetadata(self, version_number): pass

    # Attempts to store 'contents' as metadata version
    # 'version_number'.  It returns false if it already exists (and also
    # forbid concurrent puts of the same new version).
    # TODO(dpeng): Is this actually implementable??
    @abstractmethod
    def PutMetadata(self, version_number, contents): pass

    # Stores the filehandle's contents.  Raises an exception if it
    # fails to have the expected MD5 and length.
    #
    # filehandle_factory produces the same filehandle each time it's
    # invoked.  We need to be able to do multiple passes over the file
    # in case there is a retry.
    @abstractmethod
    def PutChunk(self, filehandle_factory, expected_md5, expected_length): pass

    # Fetches the file indexed by 'md5sum' and writes it to 'filehandle'.
    @abstractmethod
    def GetChunk(self, md5, expected_length, filehandle): pass

    # Returns a list of (md5, length).
    @abstractmethod
    def ListChunks(self): pass
